/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaz.FuncionPanels;

import interfaz.InterfazProcesoLU;
import interfaz.NuMethodApp;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

import metodos.sistec.Cholesky;
import metodos.sistec.Croult;
import metodos.sistec.Dolytle;
import metodos.sistec.FactorizacionPivParcial;
import metodos.sistec.FactorizacionSimple;

/**
 *
 * @author The NuMethod Team
 */
public class PanelFactorizacionLU extends javax.swing.JPanel {

    public static final String DOLYTLE = "dolytle";
    public static final String CHOLESKY = "cholesky";
    public static final String SIMPLE = "simple";
    public static final String CROULT = "croult";
    public static final String PARCIAL = "parcial";

    public PanelFactorizacionLU() {
        initComponents();
        initComponents2();
    }

    private void initComponents2() {
        TableA.setShowGrid(true);
        TableA.setOpaque(true);
        TableA.setAutoStartEditOnKeyStroke(true);
        TableA.setRolloverEnabled(true);
        TableA.setSurrendersFocusOnKeystroke(true);
        TableA.setTerminateEditOnFocusLost(true);
        TableA.setFillsViewportHeight(true);

        TableA.setEditable(false);
        TableB.setEditable(false);
        TableX.setEditable(false);
        TableA.setVisibleColumnCount(0);

        rebuildTableModels(3);

        interfazProcesoLU = new InterfazProcesoLU();
        lastExec = "";
    }

    /**
     * Este metodo devuelve los valores existentes en las tablas a dos variables
     * <br>Pasadas como parametro.
     * 
     * <p>
     * WARNING: esta version hasta ahora no soporta variables distintas a numeros<br>
     * asi que se debe de tener cuidado de no ingresar ningun valor que no sea numerico en las tablas.
     * @param A
     * @param B
     */
    private void getDataFromTables(double[][] A, double[] B) {
        int rowCount = this.TableA.getModel().getRowCount();
        int columnCount = this.TableA.getModel().getColumnCount();
        // A = new double[rowCount][columnCount];
        //Obtener los datos desde el modelo de tabla actual
        for (int i = 0; i < rowCount; i++) {
            for (int j = 0; j < columnCount; j++) {
                A[i][j] = Double.parseDouble(TableA.getModel().getValueAt(i, j).toString());
                System.out.print(Double.parseDouble(this.TableA.getModel().getValueAt(i, j).toString()) + " ");
            }
            System.out.println("");
        }

        //Obtener los datos desde la tabla B
        //B = new double[rowCount];
        for (int i = 0; i < B.length; i++) {
            B[i] = Double.parseDouble(TableB.getModel().getValueAt(i, 0).toString());
        }

    }

    /**
     * Este metodo coloca datos tipo Double en la tabla X.
     * <br>WARNING: este metodo depende estrictamente de sus valores, cualquier intento de
     * <br>utilizar este metodo con unos datos extraños terminara en error
     * @param X los datos a poner en la tablaX
     */
    private void setDataToTableX(double[] X) {
        Double[] aX = new Double[X.length];
        int n = X.length;
        //La tabla solo recibe objetos tipo Double con "D" mayuscula, el tipo basico double con "d" minuscula no es un Object.
        for (int i = 0; i < n; i++) {
            aX[i] = new Double(X[i]);
        }

        DefaultTableModel t = (DefaultTableModel) TableX.getModel();

        for (int i = 0; i < n; i++) {
            t.setValueAt(aX[i], 0, i);
        }

        //Actualizar los datos en la tabla
        t.fireTableDataChanged();

    }

    public void updateTableModels() {
        //COnfigurar los modelos de tabla para las 3 tablas disponibles.
        DefaultTableModel m = PanelMatriz.getMa();
        this.TableA.setModel(m);

        DefaultTableModel mB = PanelMatriz.getMb();
        this.TableB.setModel(mB);

        DefaultTableModel mX = PanelMatriz.getMx();
        TableX.setModel(mX);

        m.fireTableDataChanged();
        mB.fireTableDataChanged();
        mX.fireTableDataChanged();
    }

    /**
     * Metodo que reconstruye de forma dinamica los modelos de tabla
     * luego de cada entrada de datos
     * @param a
     */
    private void rebuildTableModels(Integer a) {
        //Constuir el modelo para la tabla A
        Double[][] test = new Double[a][a];
        String[] names = new String[a];

        for (int i = 0; i < a; i++) {
            String aTest = "X" + (i + 1);
            names[i] = aTest;
        }

        //Constuir el modelo para la tabla B
        Double[][] testB = new Double[a][1];
        String[] namesB = new String[1];

        for (int i = 0; i < 1; i++) {
            String aTest = "B" + (i + 1);
            namesB[i] = aTest;
        }

        //Construir el Modelo para la tabla X
        Double[][] testX = new Double[1][a];
        String[] namesX = new String[a];


        for (int i = 0; i < a; i++) {
            String aTest = "X" + (i + 1);
            namesX[i] = aTest;
        }

        //COnfigurar los modelos de tabla para las 3 tablas disponibles.
        DefaultTableModel m = new DefaultTableModel(test, names);
        this.TableA.setModel(m);

        DefaultTableModel mB = new DefaultTableModel(testB, namesB);
        this.TableB.setModel(mB);

        DefaultTableModel mX = new DefaultTableModel(testX, namesX);
        TableX.setModel(mX);

        //        for (int i =0; i < a; i++ ){
        //            for (int j= 0; j < a; j++){
        //                jTable1.setValueAt(25, i, j);
        //            }
        //        }
        m.fireTableDataChanged();
        mB.fireTableDataChanged();
        mX.fireTableDataChanged();
        //TableA.repaint();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        TableA = new org.jdesktop.swingx.JXTable();
        jButton2 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        TableB = new org.jdesktop.swingx.JXTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        TableX = new org.jdesktop.swingx.JXTable();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        BotonFactGaussPivParcial = new javax.swing.JButton();
        BotonCroult = new javax.swing.JButton();
        BotonCholesky = new javax.swing.JButton();
        BotonDolyttle = new javax.swing.JButton();
        BotonFactGaussSimple = new javax.swing.JButton();
        btnLU = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        setToolTipText("Factorizacion LU");

        TableA.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(TableA);

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/help.png"))); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        TableB.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "Title 1"
            }
        ));
        jScrollPane2.setViewportView(TableB);

        TableX.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(TableX);

        jLabel4.setText("Matriz A");

        jLabel5.setText("Vector B");

        jLabel6.setText("Vector X");

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Factorizacion LU"));

        BotonFactGaussPivParcial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/kformula.png"))); // NOI18N
        BotonFactGaussPivParcial.setText("Factorizacion con Pivoteo Parcial");
        BotonFactGaussPivParcial.setToolTipText("Factorizacion Mediante Pivoteo Parcial");
        BotonFactGaussPivParcial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonFactGaussPivParcialActionPerformed(evt);
            }
        });

        BotonCroult.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/kdevelop.png"))); // NOI18N
        BotonCroult.setText("Factorizacion de Croult");
        BotonCroult.setToolTipText("Factorizacion por Croult");
        BotonCroult.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonCroultActionPerformed(evt);
            }
        });

        BotonCholesky.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/katomic.png"))); // NOI18N
        BotonCholesky.setText("Factorizacion de Cholesky");
        BotonCholesky.setToolTipText("Factorizacion por Cholesky");
        BotonCholesky.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonCholeskyActionPerformed(evt);
            }
        });

        BotonDolyttle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/kappfinder.png"))); // NOI18N
        BotonDolyttle.setText("Factorizacion de Dolytle");
        BotonDolyttle.setToolTipText("Factorizacion por Dolyttle");
        BotonDolyttle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonDolyttleActionPerformed(evt);
            }
        });

        BotonFactGaussSimple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/recursos/kodo.png"))); // NOI18N
        BotonFactGaussSimple.setText("Factorizacion Gaussiana Simple");
        BotonFactGaussSimple.setToolTipText("Factorizacion utilizando eliminacion Gaussiana");
        BotonFactGaussSimple.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BotonFactGaussSimpleActionPerformed(evt);
            }
        });

        btnLU.setText("Ver matrices L y U");
        btnLU.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLUActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(BotonDolyttle, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BotonFactGaussSimple, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BotonCroult, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(26, 26, 26)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(BotonCholesky, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(BotonFactGaussPivParcial, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(130, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(479, Short.MAX_VALUE)
                .addComponent(btnLU)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BotonFactGaussSimple)
                    .addComponent(BotonCholesky))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BotonFactGaussPivParcial)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(BotonCroult)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BotonDolyttle)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
                .addComponent(btnLU))
        );

        jLabel1.setText("Factorizacion LU");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 510, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5))
                .addGap(2, 2, 2)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane2, 0, 0, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addGap(1, 1, 1)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        NuMethodApp.helpLauncher("FactorizacionLU");

    }//GEN-LAST:event_jButton2ActionPerformed

    private void BotonCroultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonCroultActionPerformed
        int rowCount = this.TableA.getModel().getRowCount();
        int columnCount = this.TableA.getModel().getColumnCount();
        double[][] A = new double[rowCount][columnCount];
        double[] B = new double[rowCount];
        double[] X = new double[columnCount];

        //Llenar las variable A y B desde las tablas
        getDataFromTables(A, B);

        //Las variables estan llenas si se garantiza que habian numeros en las tablas
        //Usarlas
        X = Croult.solucionar(A, B);
        //Metodo para colocar datos en la tablaX
        setDataToTableX(X);
        lastExec = CROULT;
}//GEN-LAST:event_BotonCroultActionPerformed

    private void BotonFactGaussSimpleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonFactGaussSimpleActionPerformed
        int rowCount = this.TableA.getModel().getRowCount();
        int columnCount = this.TableA.getModel().getColumnCount();
        double[][] A = new double[rowCount][columnCount];
        double[] B = new double[rowCount];
        double[] X = new double[columnCount];

        //Llenar las variable A y B desde las tablas
        getDataFromTables(A, B);

        //Las variables estan llenas si se garantiza que habian numeros en las tablas
        //Usarlas
        X = FactorizacionSimple.solucionar(A, B);
        //Metodo para colocar datos en la tablaX
        setDataToTableX(X);
        lastExec = SIMPLE;
}//GEN-LAST:event_BotonFactGaussSimpleActionPerformed

    private void BotonFactGaussPivParcialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonFactGaussPivParcialActionPerformed
        try {
            int rowCount = this.TableA.getModel().getRowCount();
            int columnCount = this.TableA.getModel().getColumnCount();
            double[][] A = new double[rowCount][columnCount];
            double[] B = new double[rowCount];
            double[] X = new double[columnCount];

            //Llenar las variable A y B desde las tablas
            getDataFromTables(A, B);

            //Las variables estan llenas si se garantiza que habian numeros en las tablas
            //Usarlas
            X = FactorizacionPivParcial.solucionar(A, B);
            //Metodo para colocar datos en la tablaX
            setDataToTableX(X);
            lastExec = PARCIAL;
        } catch (NullPointerException e) {
            JOptionPane.showMessageDialog(this, "Ha sucedido el siguiente error" +
                    "\n " + e.getLocalizedMessage());
        }
    }//GEN-LAST:event_BotonFactGaussPivParcialActionPerformed

    private void BotonDolyttleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonDolyttleActionPerformed
        int rowCount = this.TableA.getModel().getRowCount();
        int columnCount = this.TableA.getModel().getColumnCount();
        double[][] A = new double[rowCount][columnCount];
        double[] B = new double[rowCount];
        double[] X = new double[columnCount];

        //Llenar las variable A y B desde las tablas
        getDataFromTables(A, B);

        //Las variables estan llenas si se garantiza que habian numeros en las tablas
        //Usarlas
        X = Dolytle.solucionar(A, B);
        //Metodo para colocar datos en la tablaX
        setDataToTableX(X);
        lastExec = DOLYTLE;
    }//GEN-LAST:event_BotonDolyttleActionPerformed

    private void BotonCholeskyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotonCholeskyActionPerformed
        int rowCount = this.TableA.getModel().getRowCount();
        int columnCount = this.TableA.getModel().getColumnCount();
        double[][] A = new double[rowCount][columnCount];
        double[] B = new double[rowCount];
        double[] X = new double[columnCount];

        //Llenar las variable A y B desde las tablas
        getDataFromTables(A, B);

        //Las variables estan llenas si se garantiza que habian numeros en las tablas
        //Usarlas
        X = Cholesky.solucionar(A, B);
        //Metodo para colocar datos en la tablaX
        setDataToTableX(X);
        lastExec = CHOLESKY;
    }//GEN-LAST:event_BotonCholeskyActionPerformed

    private void btnLUActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLUActionPerformed
        if (lastExec.equals(SIMPLE)) {
            interfazProcesoLU.setL(FactorizacionSimple.getL());
            interfazProcesoLU.setU(FactorizacionSimple.getU());
            interfazProcesoLU.getLabelStatus().setText("Ultima Ejecucion: Factorizacion Mediante Eliminacion Gaussiana Simple");
            interfazProcesoLU.imprimirMatrices();
            interfazProcesoLU.setVisible(true);
        } else if (lastExec.equals(PARCIAL)) {
            interfazProcesoLU.setL(FactorizacionPivParcial.getL());
            interfazProcesoLU.setU(FactorizacionPivParcial.getU());
            interfazProcesoLU.imprimirMatrices();
            interfazProcesoLU.getLabelStatus().setText("Ultima Ejecucion: Factorizacion por Eliminacion Gaussiana con Pivoteo Parcial");
            interfazProcesoLU.setVisible(true);
        } else if (lastExec.equals(CROULT)) {
            interfazProcesoLU.setL(Croult.getL());
            interfazProcesoLU.setU(Croult.getU());
            interfazProcesoLU.imprimirMatrices();
            interfazProcesoLU.getLabelStatus().setText("Ultima Ejecucion: Metodo de Croult");
            interfazProcesoLU.setVisible(true);
        } else if (lastExec.equals(DOLYTLE)) {
            interfazProcesoLU.setL(Dolytle.getL());
            interfazProcesoLU.setU(Dolytle.getU());
            interfazProcesoLU.imprimirMatrices();
            interfazProcesoLU.getLabelStatus().setText("Ultima Ejecucion: Metodo de Dolytle");
            interfazProcesoLU.setVisible(true);
        } else if (lastExec.equals(CHOLESKY)) {
            interfazProcesoLU.setL(Cholesky.getL());
            interfazProcesoLU.setU(Cholesky.getU());
            interfazProcesoLU.imprimirMatrices();
            interfazProcesoLU.getLabelStatus().setText("Ultima Ejecucion: Metodo de Cholesky");
            interfazProcesoLU.setVisible(true);
        } else if(lastExec.equals("")){
            JOptionPane.showMessageDialog(this, "No has ejecutado ningun metodo", "Oops", JOptionPane.WARNING_MESSAGE);
        }


    }//GEN-LAST:event_btnLUActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BotonCholesky;
    private javax.swing.JButton BotonCroult;
    private javax.swing.JButton BotonDolyttle;
    private javax.swing.JButton BotonFactGaussPivParcial;
    private javax.swing.JButton BotonFactGaussSimple;
    private org.jdesktop.swingx.JXTable TableA;
    private org.jdesktop.swingx.JXTable TableB;
    private org.jdesktop.swingx.JXTable TableX;
    private javax.swing.JButton btnLU;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    // End of variables declaration//GEN-END:variables
    private InterfazProcesoLU interfazProcesoLU;
    private String lastExec;

    public static void main(String[] args) {
        JFrame myFrame = new JFrame("Test");
        PanelFactorizacionLU m = new PanelFactorizacionLU();
        //myFrame.setLayout(new FlowLayout());
        myFrame.add(m);

        myFrame.pack();
        myFrame.setVisible(true);


    }
}
